﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CodeDom;

namespace NeuroSpeech.XamlExtensions
{
    public abstract class GenericConverter<T> : DefaultConverter
    {


        #region public override bool  RequiresCasting(XamlCodeContext context)
        public override bool RequiresCasting(XamlCodeContext context)
        {
            return false;
        }
        #endregion



        #region public override bool  CanProcess(XamlCodeContext context)
        public override bool CanProcess(XamlCodeContext context)
        {

            Type type = context.Peek.Value.ValueType;
            if (type != null) {
                return typeof(T).IsAssignableFrom(type);
            }

            return false;
        }
        #endregion


        #region public override System.CodeDom.CodeStatement  Assign(XamlCodeContext context, System.CodeDom.CodeExpression target, System.CodeDom.CodeExpression value)
        /*public override CodeStatement Assign(XamlCodeContext context, CodeExpression target, CodeExpression value)
        {
            return new CodeCommentStatement
            {
                Comment = new CodeComment { 
                    Text = "Extension " + typeof(T).FullName + " not supported"
                }
            };
        }*/
        #endregion


    }
}
